home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Tools / ClassAct / AmigaE / ConnectExample.e < prev    next >
Text File  |  2002-03-03  |  6KB  |  167 lines

  1. /* ClassAct Inter-Connection Notification Example
  2.    Ported to E by Eric Sauvageau.
  3. */
  4.  
  5. OPT PREPROCESS
  6.  
  7. MODULE 'tools/boopsi'
  8.  
  9. MODULE 'exec/nodes','intuition','graphics','intuition/intuition',
  10.        'intuition/gadgetclass','intuition/imageclass',
  11.        'intuition/intuitionbase','intuition/classusr',
  12.        'intuition/gadgetclass','intuition/cghooks','intuition/icclass',
  13.        'intuition/classes'
  14.  
  15. MODULE 'libraries/gadtools','intuition/icclass','dos','dos/dos',
  16.        'graphics','intuition','intuition/intuition','utility/tagitem'
  17.  
  18.  
  19. MODULE 'window','classes/window','layout','gadgets/layout','gadgets/palette',
  20.        'gadgets/button','images/bevel','palette','images/label','label',
  21.        'classes/window','other/classact_macros','button'
  22.  
  23.  
  24. CONST ID_BUTTON = 1
  25. CONST ID_FOREGROUND = 2
  26. CONST ID_BACKGROUND = 3
  27.  
  28.  
  29. PROC main()
  30.  
  31. DEF window:PTR TO window,
  32.     but_object:PTR TO object,
  33.     win_object:PTR TO object,
  34.     mapfg2button, mapbg2button,
  35.     tmpres1,tmpres2
  36.  
  37. DEF wait, signal, result, done=FALSE, code
  38.  
  39.  
  40.    mapfg2button := [PALETTE_COLOR, BUTTON_TEXTPEN, TAG_END]
  41.    mapbg2button := [PALETTE_COLOR, BUTTON_BACKGROUNDPEN, TAG_END]
  42.  
  43.    windowbase  := OpenLibrary('window.class',0)
  44.    layoutbase  := OpenLibrary('gadgets/layout.gadget',0)
  45.    buttonbase  := OpenLibrary('gadgets/button.gadget',0)
  46.    palettebase := OpenLibrary('gadgets/palette.gadget',0)
  47.    labelbase   := OpenLibrary('images/label.image',0)
  48.  
  49.    IF (windowbase AND layoutbase AND buttonbase AND palettebase AND labelbase)
  50.  
  51. -> Create the window object.
  52.  
  53.       win_object := WindowObject,
  54.                         WA_SCREENTITLE, 'ClassAct Copyright 1995, Phantom Development LLC.',
  55.                         WA_TITLE, 'ClassAct Example',
  56.                         WA_SIZEGADGET, TRUE,
  57.                         WA_LEFT, 40,
  58.                         WA_TOP, 30,
  59.                         WA_DEPTHGADGET, TRUE,
  60.                         WA_DRAGBAR, TRUE,
  61.                         WA_CLOSEGADGET, TRUE,
  62.                         WA_ACTIVATE, TRUE,
  63.                         WA_SMARTREFRESH, TRUE,
  64.  
  65.                         WINDOW_PARENTGROUP, VLayoutObject,
  66.                            LAYOUT_SPACEOUTER, TRUE,
  67.                            LAYOUT_DEFERLAYOUT, TRUE,
  68.                            LAYOUT_BEVELSTYLE, GroupFrame,
  69.                            LAYOUT_LABEL, 'InterConnection',
  70.  
  71.                            StartMember, but_object := ButtonObject,
  72.                               GA_TEXT, '_Inter-Connection Example',
  73.                               GA_ID, ID_BUTTON,
  74.                            EndMember,
  75.                            CHILD_WEIGHTEDHEIGHT, 0,
  76.  
  77.                            StartMember, HLayoutObject,
  78.                               LAYOUT_SPACEOUTER, FALSE,
  79.  
  80.                               StartMember, PaletteObject,
  81.                                  GA_ID, ID_FOREGROUND,
  82.                                  PALETTE_NUMCOLORS, 8,
  83.                                  PALETTE_COLOR, 1,
  84.                                  ICA_TARGET, but_object, /* object to connect to */
  85.                                  ICA_MAP, mapfg2button, /* tag mapping array */
  86.                               EndMember,
  87.                               CHILD_LABEL, LabelObject, LABEL_TEXT, '_ForeGround', LabelEnd,
  88.                               CHILD_MINWIDTH, 90,
  89.                               CHILD_MINHEIGHT, 20,
  90.  
  91.                               StartMember, PaletteObject,
  92.                                  GA_ID, ID_BACKGROUND,
  93.                                  PALETTE_NUMCOLORS, 8,
  94.                                  PALETTE_COLOR, 0,
  95.                                  ICA_TARGET, but_object, /* object to connect to */
  96.                                  ICA_MAP, mapbg2button, /* tag mapping array */
  97.                              EndMember,
  98.                              CHILD_LABEL, LabelObject,  LABEL_TEXT, '_BackGround', LabelEnd,
  99.                              CHILD_MINWIDTH, 90,
  100.                              CHILD_MINHEIGHT, 20,
  101.                           EndMember,
  102.                        EndMember,
  103.                     EndWindow
  104.  
  105. -> Object creation sucessful?
  106.  
  107.       IF win_object
  108.  
  109. -> Open the window.
  110.  
  111.          IF (window := CA_OpenWindow(win_object))
  112.  
  113. -> Obtain the window wait signal mask.
  114.  
  115.             GetAttr(WINDOW_SIGMASK, win_object, {signal})
  116.  
  117. -> Input Event Loop
  118.  
  119.             WHILE (done = FALSE)
  120.                wait := Wait(signal OR SIGBREAKF_CTRL_C)
  121.                     
  122.                IF (wait AND SIGBREAKF_CTRL_C)
  123.                   done := TRUE
  124.  
  125.                ELSE
  126.  
  127.                   WHILE ((result := CA_HandleInput(win_object,{code})) <> WMHI_LASTMSG)
  128.  
  129.                      tmpres1 := (result AND WMHI_CLASSMASK)
  130.  
  131.                      SELECT tmpres1
  132.  
  133.                         CASE WMHI_CLOSEWINDOW ; done := TRUE
  134.  
  135.                         CASE WMHI_GADGETUP
  136.                            tmpres2 := (result AND WMHI_GADGETMASK)
  137.  
  138.                            SELECT tmpres2
  139.                              CASE ID_BUTTON ; NOP
  140.                            ENDSELECT
  141.  
  142.                      ENDSELECT
  143.  
  144.                   ENDWHILE
  145.                ENDIF
  146.             ENDWHILE
  147.          ENDIF
  148.  
  149.          /* Disposing of the window object will
  150.           * also close the window if it is
  151.           * already opened and it will dispose of
  152.           * all objects attached to it.
  153.           */
  154.         DisposeObject(win_object )
  155.       ENDIF
  156.    ENDIF
  157.  
  158. -> Close the classes.
  159.  
  160.    IF labelbase   THEN CloseLibrary(labelbase)
  161.    IF palettebase THEN CloseLibrary(palettebase)
  162.    IF buttonbase  THEN CloseLibrary(buttonbase)
  163.    IF layoutbase  THEN CloseLibrary(layoutbase)
  164.    IF windowbase  THEN CloseLibrary(windowbase)
  165.  
  166. ENDPROC
  167.